package behavior_analysis_model;

import java.util.Comparator;


public class TimedTrackComparator implements Comparator<Object> {

	@Override
	public int compare(Object track_1, Object track_2) {
		if (track_1 == null || track_2 == null || !(track_1 instanceof TimedTrack) || !(track_2 instanceof TimedTrack)) {
			throw new IllegalArgumentException("Invalid objects for comparison.");
		}
		final long result = ((TimedTrack)track_1).getTotalTime() - ((TimedTrack)track_2).getTotalTime();
		if (result > 0.0) {
			return -1;
		} else if (result < 0.0) {
			return 1;
		} else {
			return 0;
		}
	}

}
